package cn.edu.neusoft.maxingxin231.yuejian06.Activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import cn.edu.neusoft.maxingxin231.yuejian06.R;

public class TrainDetailActivity extends BaseActivity {
    Context context;
    String train_id,train_name,train_pic,train_type,train_intro,train_time,train_address,train_price;
    TextView tv_detail,tv_user,tv_trainname,tv_traintype,tv_trainintro,tv_trainaddress,tv_traintime,tv_trainprice;
    ImageView img_train,img_user;
    ImageButton imgbtn_return,imgbtn_collect;
    Button btn_buy;
    @Override
    void initView() {
        setLayout_file(R.layout.activity_train_detail);
        imgbtn_return = (ImageButton)findViewById(R.id.imgbtn_return);
        imgbtn_collect = (ImageButton)findViewById(R.id.imgbtn_collect);
        tv_detail = (TextView)findViewById(R.id.tv_detail);
        tv_user = (TextView)findViewById(R.id.tv_user);
        tv_trainname = (TextView)findViewById(R.id.tv_trainname);
        tv_traintype = (TextView)findViewById(R.id.tv_traintype);
        tv_trainintro = (TextView)findViewById(R.id.tv_trainintro);
        tv_trainaddress = (TextView)findViewById(R.id.tv_trainaddress);
        tv_traintime = (TextView)findViewById(R.id.tv_traintime);
        tv_trainprice = (TextView)findViewById(R.id.tv_trainprice);
        img_train = (ImageView)findViewById(R.id.img_train);
        img_user = (ImageView)findViewById(R.id.img_user);
        btn_buy=(Button)findViewById(R.id.btn_buy);

        train_id = getIntent().getStringExtra("train_id");
        train_name = getIntent().getStringExtra("train_name");
        train_pic = getIntent().getStringExtra("train_pic");
        train_intro = getIntent().getStringExtra("train_intro");
        train_type = getIntent().getStringExtra("train_type");
        train_time = getIntent().getStringExtra("train_time");
        train_address = getIntent().getStringExtra("train_address");
        train_price = getIntent().getStringExtra("train_price");

        tv_trainname.setText(train_name);
        tv_trainintro.setText(train_intro);
        Picasso.with(TrainDetailActivity.this).load("http://10.0.2.2:80/yuejian14/public/static/trains/"+train_pic).into(img_train);
        showToast(train_name);
    }

    @Override
    void initEvent() {
        imgbtn_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        btn_buy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(TrainDetailActivity.this,TrainApplyActivity.class);
                intent.putExtra("train_id",train_id);
                intent.putExtra("train_name",train_name);
                intent.putExtra("train_intro",train_intro);
                intent.putExtra("train_type",train_type);
                startActivityForResult(intent,1);
            }
        });
    }

    @Override
    void initData() {

    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {

    }
}
